package com.dds.web.controller;

import com.dds.common.core.domain.AjaxResult;
import com.dds.system.service.union.IUnionShopIndexService;
import com.dds.system.service.union.IUnionShopOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gaolianjie
 * @create 2021/3/31
 */
@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private IUnionShopIndexService shopIndexService;

    @Autowired
    private IUnionShopOrderService shopOrderService;

    @GetMapping("/getData")
    public AjaxResult index() {
        Map<String, Integer> data = shopIndexService.getIndexData();

        return AjaxResult.success("成功", data);
    }

    @GetMapping("/getOrderData")
    public AjaxResult orderData(
            @RequestParam(name = "selectDay") String selectDay
    ) {

        Map<String, Object> orderData = shopOrderService.getOrderData(selectDay);

        Map<String, Object> data = new HashMap<>(orderData);

        return AjaxResult.success(data);
    }
}
